home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 10
/
FM Towns Free Software Collection 10.iso
/
ms_dos
/
tool
/
conhlp03
/
padp_src
/
iscktest.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-22
|
1KB
|
68 lines
/*
iscktest.c
x=isck(x,c) : 文字種判定 x=0:1byte 1:1/2byte 2:2byte
iscktest 88あ24元気=+
iscktest 1絶大3まみ+アケタ/
*/
#include <stdio.h>
/* sjis 上位:81h-9fh e0h-efh 下位:3fh-fbh !7fh */
#define isk1(c) ( 0x81<=(c) && (c)<=0x9f || 0xe0<=(c) && (c)<=0xef )
#define isk2(c) ( 0x3f<=(c) && (c)<=0xfb && (c) != 0x7f )
#define isck(x,c) (x==0)?(isk1(c)?1:0):(x==1)?2:(x==2)?(isk1(c)?1:0):0;
int exit(int);
void main( int argc, char *argv[] ){
int k,i;
char c;
if( argc!=2 ){ fputs( argv[0],stderr ); exit(1); }
for( i = 0 ; ( c = argv[1][i] ) != NULL ; i++ ){
printf("%02X/",c );
}
cputs("\r\n");
k = 0;
for( i = 0 ; ( c = argv[1][i] ) != NULL ; i++ ){
switch ( k ) {
case 0:
if( isk1(c) ) k = 1;
else k = 0;
break;
case 1:
k = 2;
break;
case 2:
if( isk1(c) ) k = 1;
else k = 0;
break;
default:
exit(0);
break;
}
if( k == 0 ) putch('|');
if( k == 1 ) putch('>');
putch( c );
}
cputs("\r\n");
k = 0;
for( i = 0 ; ( c = argv[1][i] ) != NULL ; i++ ){
k = ( k == 0 ) ? ( isk1(c) ? 1 : 0 )
: ( k == 1 ) ? 2
: ( k == 2 ) ? ( isk1(c) ? 1 : 0 ) : 0 ;
if( k == 0 ) putch('|');
if( k == 1 ) putch('>');
putch( c );
}
cputs("\r\n");
k = 0;
for( i = 0 ; ( c = argv[1][i] ) != NULL ; i++ ){
k = isck( k,c );
if( k == 0 ) putch('|');
if( k == 1 ) putch('>');
putch( c );
}
}